import numpy as np
import matplotlib.pyplot as plt
from rk45 import cal_temperature

R_1 = 0.0012
R_2 = 0.0093
C_in = 1100000
C_wall = 186000000
theta_out = 0
dt = 1
cal_temp =  cal_temperature(dt, R_1, R_2, C_in, C_wall)
cal_temp.reset_B_P()
cal_temp.reset_out_tempurature(theta_out)
cal_temp.set_start_theta(0, 18)
temp_list = []
temp_wall_list = []

x_axis = []
x_index = 0
P_status = []
for i in range(86400*10):
    cal_temp.rk45()
    if (cal_temp.get_theta()[0,0] < 18):
        cal_temp.reset_B_P()
    #     print("less than 18,now temp %d"%cal_temp.get_theta()[0,0])
    
    elif (cal_temp.get_theta()[0,0] > 22):
        cal_temp.reset_B_0()
    #     print("over 22,now temp %d"%cal_temp.get_theta()[0,0])
    temp_list.append(cal_temp.get_theta()[0,0])
    P_status.append(cal_temp.P_status)
    temp_wall_list.append(cal_temp.get_theta()[1,0])
    x_index +=1
    x_axis.append(x_index)


x_axis = np.asarray(x_axis)

temp_list = np.asarray(temp_list)
temp_wall_list = np.asarray(temp_wall_list)
plt.plot(x_axis/3600,temp_list)

plt.plot(x_axis/3600,temp_wall_list)
plt.show()